package com.sykj.why.exception;

import com.sykj.why.mongo.enums.exception.ResultEnum;
import lombok.Getter;

/**
 * @author Mr.will
 * @date 2018/8/3 13:50
 * @Desc 自定义异常
 */
@Getter
public class WhyException extends RuntimeException {
    private Integer code;

    public WhyException(ResultEnum resultEnum) {
        super(resultEnum.getMessage());
        this.code = resultEnum.getCode();
    }


    public WhyException(Integer code, String msg) {
        super(msg);
        this.code = code;
    }


    public WhyException(String fileName, ResultEnum resultEnum) {
        super(fileName + resultEnum.getMessage());
        this.code = resultEnum.getCode();
    }

    public WhyException(String errorMsg) {
        super(errorMsg);
        this.code = ResultEnum.UNERROR.getCode();
    }

}
